package zhu.areas.hatchnav.action;

import java.util.Date;
import java.util.List;

import zhu.areas.hatchnav.data.Article;
import zhu.areas.hatchnav.service.IArticlePubService;
import zhu.areas.hatchnav.service.IArticleRankService;
import zhu.areas.hatchnav.service.IArticleShowService;
import zhu.common.data.Pager;

import com.opensymphony.xwork2.ActionSupport;

/*
 * 分页显示文章的简略信息
 */
public class ShowArticlesAction extends ActionSupport {
	/*
	 * 不需要 private int articleID;// 文章ID private String articleTitle; private
	 * String partialContent; private String articleContent; private int
	 * publisher;// 发布人ID private String publisherName; private Date pubTime;
	 * private int artType; private int visitNum;
	 */
	private IArticleShowService articleshowService;
	private IArticleRankService articleRankService;
	
	private List<Article> articlelist;
	private List<Article> articleTopList;
	private int topCount = 5;

	private Pager pager;
	private String currentPage;
	private String pageMethod;
	private Integer pageSize = 2;// 每页显示的记录数目

	private String title;

	// 显示职业规划的相关文章
	public String showCareerPlans() {
		title = "职业规划";
		this.pager = this.articleshowService.findPageCareerArticles(pageSize,
				currentPage, pageMethod);
		
		System.out.println("pager对象："+pager.getTotalPages());
		
		this.articlelist = this.pager.getList();
		
		this.setCurrentPage(String.valueOf(this.pager.getCurrentPage()));

		// 查找访问量排名前5的职业规划文章
		this.articleTopList = this.articleRankService
				.findTopCareerArticlesByVisitNum(topCount);

		return SUCCESS;
	}

	// 显示政策解读的相关文章
	public String showPolicyElabs() {
		title = "政策解读";
		this.pager = this.articleshowService.findPagePolicyArticles(pageSize,
				currentPage, pageMethod);
		this.articlelist = this.pager.getList();
		this.setCurrentPage(String.valueOf(this.pager.getCurrentPage()));

		// 查找访问量排名前5的政策解读文章
		this.articleTopList = this.articleRankService
				.findTopPolicyArticlesByVisitNum(topCount);

		return SUCCESS;
	}

	// 显示热点评论的相关文章
	public String showHotComment() {
		title = "热点评论";
		this.pager = this.articleshowService.findPageCommentArticles(pageSize,
				currentPage, pageMethod);
		this.articlelist = this.pager.getList();
		this.setCurrentPage(String.valueOf(this.pager.getCurrentPage()));

		// 查找访问量排名前5的热点评论文章
		this.articleTopList = this.articleRankService
				.findTopCommentArticlesByVisitNum(topCount);

		return SUCCESS;
	}

	// 显示中心新闻的相关文章
	public String showCenterNews() {
		title = "中心新闻";
		this.pager = this.articleshowService.findPageNewsArticles(pageSize,
				currentPage, pageMethod);
		this.articlelist = this.pager.getList();
		this.setCurrentPage(String.valueOf(this.pager.getCurrentPage()));

		// 查找访问量排名前5的中心新闻文章
		this.articleTopList = this.articleRankService
				.findTopNewsArticlesByVisitNum(topCount);

		return SUCCESS;
	}

	// 显示通知公告的相关文章
	public String showNoticeAnnos() {
		title = "通知公告";
		this.pager = this.articleshowService.findPageNoticeArticles(pageSize,
				currentPage, pageMethod);
		this.articlelist = this.pager.getList();
		this.setCurrentPage(String.valueOf(this.pager.getCurrentPage()));

		// 查找访问量排名前5的通知公告文章
		this.articleTopList = this.articleRankService
				.findTopNoticeArticlesByVisitNum(topCount);

		return SUCCESS;
	}

	public IArticleShowService getArticleshowService() {
		return articleshowService;
	}

	public void setArticleshowService(IArticleShowService articleshowService) {
		this.articleshowService = articleshowService;
	}

	public IArticleRankService getArticleRankService() {
		return articleRankService;
	}

	public void setArticleRankService(IArticleRankService articleRankService) {
		this.articleRankService = articleRankService;
	}

	public List<Article> getArticlelist() {
		return articlelist;
	}

	public void setArticlelist(List<Article> articlelist) {
		this.articlelist = articlelist;
	}

	public Pager getPager() {
		return pager;
	}

	public void setPager(Pager pager) {
		this.pager = pager;
	}

	public String getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(String currentPage) {
		this.currentPage = currentPage;
	}

	public String getPageMethod() {
		return pageMethod;
	}

	public void setPageMethod(String pageMethod) {
		this.pageMethod = pageMethod;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public List<Article> getArticleTopList() {
		return articleTopList;
	}

	public void setArticleTopList(List<Article> articleTopList) {
		this.articleTopList = articleTopList;
	}

	public int getTopCount() {
		return topCount;
	}

	public void setTopCount(int topCount) {
		this.topCount = topCount;
	}
}
